/**
 * Created by zhangzhihao on 2016/12/06 11:00;
 */
var vm = new Vue({
    el: "#main",
    data: {
        listArry: [],
        id: "",
        businessNo: "",
        stateValue: "",
        appliName: "",
        nowPage:1,
        rowNum:10,
        allPages:0,
        pagination: [],
        applyCondition:'',//申请条件
        organCode:'',//结构代码
        jsonStr:'',//json串
        tipMsg: '', // 弹出框提示信息
    },
    created: function() {
        this.queryUser();
    },
    methods: {
         //分页
         selectPage(page){
            this.nowPage = page;
            this.queryUser();
        },
        skipPage() {
        	this.nowPage = parseInt(document.getElementById('page-num').value);
        	document.getElementById('page-num').value = '';
            this.queryUser();
        },
        offsetPage(offset){
            this.nowPage = parseInt(this.nowPage) + parseInt(offset);
            this.queryUser();
        },
        queryUser() {
            const _this = this;
            /*if(!_this.appliName && !_this.businessNo && !_this.organCode && !_this.jsonStr) {
                _this.tipMsg = '查询条件不能为空'
                $('#my-alert1').modal({
                    relatedTarget: this,
                });
                return false
            }*/
			_this.listArry = []
            let obj = {
                appliName: _this.appliName,
                businessNo: _this.businessNo, //业务识别号（保单号）
                nowPage:this.nowPage,
                rowNum:this.rowNum,
                organCode:this.organCode,
                projson:this.jsonStr,
            };
            axios({
                    method: "post",
                    // url: "http://localhost:9000/slxt-web/collect/queryDataList",
                    url: App.envUrl.backtrackUrl+"collect/queryDataList",
                    data: obj,
                })
                .then((data) => {
                    console.log(data.data.pageCount.datas);
                    var list = data.data.pageCount.datas;
                    // this.nowPage = data.data.pageCount.nowPage;
                    if(list.length > 0){
                        this.allPages = data.data.pageCount.allPages;
                        this.pagination = getPagination(this.nowPage,this.allPages);
                        list.forEach((element) => {
                            element.stateValue = "";
                            if (element.auditState == 0) {
                                element.stateValue = "未审核";
                            } else if (element.auditState == 1) {
                                element.stateValue = "通过";
                            } else if (element.auditState == 2) {
                                element.stateValue = "拒绝";
                            } else if (element.auditState == 3) {
                                element.stateValue = "审核中";
                            }
                        });
                        _this.listArry = list;
                    }else if(list.length == 0) {
                        _this.tipMsg = '抱歉，未查询到符合条件的数据！'
                        $('#my-alert1').modal({
                            relatedTarget: _this,
                        });
                    }
                })
                .catch((err) => {});
        },
        resetBtn() {
            const _this = this;
            _this.businessNo = "";
            _this.appliName = "";
            this.jsonStr = '';
            this.organCode = '';
            _this.listArry = []
        },
        checkdis(id, businessNo) {
            window.location.href =
                "dispute.html?id=" + id + "&businessNo=" + (businessNo || '');
        },
        checkModio(id, businessNo) {
            window.location.href =
                "newReplay_new.html?id=" + id + "&businessNo=" + (businessNo || '');
        },
        applyModio(id) {
            $('#my-alert').modal({
                relatedTarget: this,
            });
            this.id = id;
        },
        confirmBtn(){
            // console.log(id)
            axios({
                method: "post",
                url: App.envUrl.backtrackUrl+"approval/updateApplyInfo",
                data: {collectId: this.id,reqDetail: this.applyCondition,appType:'0'},
                // 申请调阅信息接口
            }).then((data) => {
                console.log(data,'申请条件反参')
            }).catch((err) => {})
        },        
        //业务信息按钮
        businessMsg(id,businessNo){
            window.location.href = "newReplayDetail.html?id=" + id + "&businessNo=" + (businessNo || '');
        },
    },
});

function rowNumChange(value) {
    vm.queryData.rowNum = value;
    vm.queryData.nowPage = 1;
    vm.queryUser();
}